//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: "气温34°",
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    a:"",
    b:"",
    result:"",
    weatherList:{},
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    var that = this;
    wx.request({
      url: 'https://v0.yiketianqi.com/api?version=v61&appid=27319492&appsecret=LUlonOV6&city=成都', //仅为示例，并非真实的接口地址
      data: {
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
            that.setData({
              weatherList:res.data
            })
            ,console.log(res.data)
      }
    })                                 
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  compare:function(e){
      
      console.log("第一个数为："+this.data.a);
      console.log("第二个数为："+this.data.b);
      if (this.data.a > this.data.b) {
        this.setData({
          result: "第一个数大"
        })
      }else{
        this.setData({
          result: "第二个数大"
        })
      }
  },
  bindA:function(e){
    this.setData({
      a: Number(e.detail.value) 
    });
    if (this.data.a > this.data.b) {
      this.setData({
        result: "第一个数大"
      })
    }else{
      this.setData({
        result: "第二个数大"
      })
    }
    console.log(Number(e.detail.value) )
  },
  bindB:function(e){
    this.setData({
      b: Number(e.detail.value) 
    });
    if (this.data.a > this.data.b) {
      this.setData({
        result: "第一个数大"
      })
    }else{
      this.setData({
        result: "第二个数大"
      })
    }
    console.log(Number(e.detail.value) )
  }
})
